package com.imdb;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TabHost;

public class HelloTabWidget extends TabActivity {

	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		Resources res = getResources(); // Resource object to get Drawables
		TabHost tabHost = getTabHost();  // The activity TabHost
		TabHost.TabSpec spec;  // Resuable TabSpec for each tab
		Intent intent;  // Reusable Intent for each tab
				
		//Ajout du FLAG

		Button b;
		(b = (Button)findViewById(R.id.flag_button)).setBackgroundDrawable(this.getResources().getDrawable(R.drawable.flag));
		/*
		b.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				// Perform action on clicks
				Context context = getApplicationContext();

				Toast.makeText(context, "BEFORE"+Locale.getDefault().toString(), Toast.LENGTH_SHORT).show();
				try{
					if (Locale.getDefault().getLanguage().equals(Locale.FRENCH.getLanguage())){ 
						Locale.setDefault(Locale.ENGLISH);
					}else if(Locale.getDefault().getLanguage().equals(Locale.ENGLISH.getLanguage())){ 
						Locale.setDefault(Locale.FRENCH);
					}
				}catch(Exception e){
					Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();	
				}
				Toast.makeText(context, "AFTER"+Locale.getDefault().toString(), Toast.LENGTH_SHORT).show();
				//A VOIR
				//XXX Reload du contentView, du intent ???
			}
		});
		*/
		//END Ajout du FLAG

		
		
		//1e Tab 
		// Create an Intent to launch an Activity for the tab (to be reused)
		intent = new Intent().setClass(this, SearchIMDB_Artist.class);
		// Initialize a TabSpec for each tab and add it to the TabHost
		//spec = tabHost.newTabSpec("artists").setIndicator("Artists",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
		spec = tabHost.newTabSpec("artists").setIndicator(res.getString(R.string.artistsLabelOnglet),res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
		tabHost.addTab(spec);	  

		//2e Tab	    
		// Do the same for the other tabs
		intent = new Intent().setClass(this, SearchIMDB_Film.class);
		//spec = tabHost.newTabSpec("films").setIndicator("Films",res.getDrawable(R.drawable.ic_tab_films)).setContent(intent);
		spec = tabHost.newTabSpec("films").setIndicator(res.getString(R.string.filmsLabelOnglet),res.getDrawable(R.drawable.ic_tab_films)).setContent(intent);
		tabHost.addTab(spec);

	}
}
